/*
 *===================================================================
 *
 *          Name: jk_print.h
 *        Create: Sat 27 Oct 2012 09:49:46 AM CST
 *
 *   Discription: 
 *       Version: 1.0.0
 *
 *        Author: yuwei.zhang
 *         Email: yuwei.zhang@besovideo.com
 *
 *===================================================================
 */
#ifndef __JK_PRINT_H
#define __JK_PRINT_H

#ifdef  __cplusplus 
#define JK_EXTERN_C_START       extern "C" {
#define JK_EXTERN_C_END         }
#define JK_EXTERN_C_FUNC        extern "C"
#else
#define JK_EXTERN_C_START
#define JK_EXTERN_C_END 
#define JK_EXTERN_C_FUNC
#endif

/* use for jk_print_level */
enum {
    JK_PRINT_NONE = 1, JK_PRINT_ERROR = 1 << 1,
    JK_PRINT_WARN = 1 << 2, JK_PRINT_INFO = 1 << 3,
    JK_PRINT_MESSAGE = 1 << 4,
    JK_PRINT_DEBUG = 1 << 5,
    JK_PRINT_CYCLE = 1 << 6,
    JK_PRINT_ALL = JK_PRINT_ERROR|JK_PRINT_WARN|JK_PRINT_INFO|JK_PRINT_DEBUG|JK_PRINT_CYCLE,
};

/* use for jk_print_style */
// you can use some of them except none and all
// none use above JK_PRINT_NONE
// time style %04y:%02m:%02d
enum {
    JK_PRINT_STYLE_ALL = 1 << 1, // [name][time][func():line@file] ==> 
    JK_PRINT_STYLE_NONE = 1 << 2,  // xxx
    JK_PRINT_NONAME = 1 << 3, // [time]...
    JK_PRINT_NOTIME = 1 << 4, // [name][func... 
    JK_PRINT_NOFUNC = 1 << 5, // [name][time][line@file] ==>
    JK_PRINT_NOLINE = 1 << 6, // [name][time][func()@file] ==>
    JK_PRINT_NOFILE = 1 << 7, // [name][time][func():line] ==>
};

enum {
    JK_COLOR_FALSE = 0,
    JK_COLOR_TRUE,
};
 
JK_EXTERN_C_FUNC int jk_print_init(int jk_print_level, 
          int jk_print_style, int jk_print_enable_color, 
          const char *name);
JK_EXTERN_C_FUNC int jk_print_deinit();

JK_EXTERN_C_FUNC int jk_print_change_level(int level);
JK_EXTERN_C_FUNC int jk_print_start_debug();
JK_EXTERN_C_FUNC int jk_print_stop_debug();
JK_EXTERN_C_FUNC int jk_print_start_cycle();
JK_EXTERN_C_FUNC int jk_print_stop_cycle();

JK_EXTERN_C_FUNC int jk_print_style_none(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_error(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_stderror(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_warn(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_info(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_message(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_debug(const char *func, int line, const char *file, const char *format, ...);
JK_EXTERN_C_FUNC int jk_print_cycle(const char *func, int line, const char *file, const char *format, ...);

/* type is JK_PRINT_* */
JK_EXTERN_C_FUNC int jk_print(int type, const char *func, int line, const char *file, const char *format, ...);

#define JKERROR(format, ...) jk_print_error(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKSTDERROR(format, ...) jk_print_stderror(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKWARN(format, ...) jk_print_warn(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKINFO(format, ...) jk_print_info(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKMSG(format, ...) jk_print_message(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKDEBUG(format, ...) jk_print_debug(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKCYCLE(format, ...) jk_print_cycle(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)
#define JKNONE(format, ...) jk_print_style_none(__func__, __LINE__, __FILE__, format, ##__VA_ARGS__)

#define JKPRINT(type, format, ...) jk_print(type, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__)

JK_EXTERN_C_FUNC int jk_print_add_kind(int kind);
JK_EXTERN_C_FUNC int jk_print_del_kind(int kind);
JK_EXTERN_C_FUNC int jk_print_kind(int kind, const char *func, int line, const char *file, const char *format, ...);
#define JKKIND(kind, format, ...) jk_print_kind(kind, __func__, __LINE__, __FILE__, format, ##__VA_ARGS__);


#endif

/*=============== End of file: jk_print.h =====================*/
